package org.lex.ftp.ui.bookmark;

import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.swing.*;

import org.lex.ftp.ui.opendialog.ConnectionPane;


public class SiteManagerPane extends JSplitPane {
	private JPanel sitePane = null;
	private JPanel optionsPane = null;
	private JPanel configPane = null;
	private JPanel buttonsPane = null;
	private JPanel gluePane = null;
	private JButton newButton = null;
	private JButton deleteButton = null;
	private JButton applyButton = null;
	private JLabel siteNameLabel = null;
	private JLabel siteLabel = null;
	private JTextField siteNameTextField = null;
	private ConnectionPane tempPanel = null;
	private Tree tree = null;
	private JPanel topPane = null;

	/**
	 * This is the default constructor
	 */
	public SiteManagerPane() {
		super();
		tree = new Tree();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(425, 325);
		this.setRightComponent(getConfigPanel());
		this.setLeftComponent(getSitePane());
		this.setOneTouchExpandable(true);
		this.setDividerSize(2);
		this.setResizeWeight(0.5D);
		this.setDividerLocation(1.0D);
	}

	/**
	 * This method initializes sitePane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getSitePane() {
		if (sitePane == null) {
			sitePane = new JPanel();
			sitePane.setLayout(new BorderLayout());
			sitePane.add(getTopPane(), java.awt.BorderLayout.NORTH);
			sitePane.add(tree, java.awt.BorderLayout.CENTER);
		}
		return sitePane;
	}

	/**
	 * This method initializes configPanel
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getConfigPanel() {
		if (optionsPane == null) {
			optionsPane = new JPanel();
			optionsPane.setLayout(new BorderLayout());
			optionsPane.add(getConfigPane(), java.awt.BorderLayout.CENTER);
			optionsPane.add(getButtonsPane(), java.awt.BorderLayout.SOUTH);
		}
		return optionsPane;
	}

	/**
	 * This method initializes configPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getConfigPane() {
		if (configPane == null) {
			GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
			gridBagConstraints11.gridx = 0;
			gridBagConstraints11.gridwidth = 2;
			gridBagConstraints11.fill = java.awt.GridBagConstraints.BOTH;
			gridBagConstraints11.weightx = 0.5;
			gridBagConstraints11.weighty = 0.5;
			gridBagConstraints11.gridy = 2;
			GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
			gridBagConstraints2.gridx = 0;
			gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;
			gridBagConstraints2.weightx = 1.0;
			gridBagConstraints2.gridwidth = 2;
			gridBagConstraints2.gridy = 1;
			GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
			gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
			gridBagConstraints1.gridy = 0;
			gridBagConstraints1.weightx = 1.0;
			gridBagConstraints1.insets = new java.awt.Insets(0, 0, 3, 5);
			gridBagConstraints1.gridx = 1;
			GridBagConstraints gridBagConstraints = new GridBagConstraints();
			gridBagConstraints.gridx = 0;
			gridBagConstraints.insets = new java.awt.Insets(0, 6, 3, 3);
			gridBagConstraints.gridy = 0;
			siteNameLabel = new JLabel();
			siteNameLabel.setText("Site Name");
			configPane = new JPanel();
			configPane.setLayout(new GridBagLayout());
			configPane.add(siteNameLabel, gridBagConstraints);
			configPane.add(getSiteNameTextField(), gridBagConstraints1);
			configPane.add(getTempPanel(), gridBagConstraints2);
			configPane.add(getGluePane(), gridBagConstraints11);
		}
		return configPane;
	}

	/**
	 * This method initializes buttonsPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getButtonsPane() {
		if (buttonsPane == null) {
			buttonsPane = new JPanel();
			buttonsPane.add(getNewButton(), null);
			buttonsPane.add(getApplyButton(), null);
			buttonsPane.add(getDeleteButton(), null);
		}
		return buttonsPane;
	}

	/**
	 * This method initializes newButton
	 * 
	 * @return javax.swing.JButton
	 */
	private JButton getNewButton() {
		if (newButton == null) {
			newButton = new JButton();
			newButton.setText("New");
		}
		return newButton;
	}

	/**
	 * This method initializes deleteButton
	 * 
	 * @return javax.swing.JButton
	 */
	private JButton getDeleteButton() {
		if (deleteButton == null) {
			deleteButton = new JButton();
			deleteButton.setText("Delete");
		}
		return deleteButton;
	}

	/**
	 * This method initializes applyButton
	 * 
	 * @return javax.swing.JButton
	 */
	private JButton getApplyButton() {
		if (applyButton == null) {
			applyButton = new JButton();
			applyButton.setText("Apply");
		}
		return applyButton;
	}

	/**
	 * This method initializes siteNameTextField
	 * 
	 * @return javax.swing.JTextField
	 */
	private JTextField getSiteNameTextField() {
		if (siteNameTextField == null) {
			siteNameTextField = new JTextField();
		}
		return siteNameTextField;
	}

	/**
	 * This method initializes tempPanel
	 * 
	 * @return javax.swing.JPanel
	 */
	private ConnectionPane getTempPanel() {
		if (tempPanel == null) {
			tempPanel = new ConnectionPane();
		}
		return tempPanel;
	}

	/**
	 * This method initializes gluePane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getGluePane() {
		if (gluePane == null) {
			gluePane = new JPanel();
		}
		return gluePane;
	}

	/**
	 * This method initializes topPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getTopPane() {
		if (topPane == null) {
			siteLabel = new JLabel();
			siteLabel.setText("Site");
			topPane = new JPanel();
			topPane.setLayout(new BorderLayout());
			topPane.add(siteLabel, java.awt.BorderLayout.WEST);
			topPane.add(new HideAndShowButton(this), BorderLayout.EAST);
		}
		return topPane;
	}
}
